package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.*;
import cn.com.headfree.mouldshow.dao.TEmpBaseInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import com.gta.edu.sdk.common.dto.Page;
import com.gta.edu.sdk.util.IdGen;
import com.gta.edu.sdk.util.StringUtil;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tEmpBaseInfoTempDao")
public class TEmpBaseInfoTempDaoImpl extends BaseDaoImpl<TEmpBaseInfoTemp> implements TEmpBaseInfoTempDao {


    @Override
    public void getTEmpBaseInfoTempPageList(Page<TEmpBaseInfoTemp> page) {
        String sql = "";
        sql = "select name,sex,birth_date,nation,birth_place,politi_status,id_card_no ";
        StringBuilder sqlbuilder = new StringBuilder(sql);
        sqlbuilder.append(" from t_emp_base_info_temp ");
        sqlbuilder.append(" order by create_time desc  ");
        this.findPageBySql(TEmpBaseInfoTemp.class, sqlbuilder.toString(), page);
    }

    @Override
    public void saveInfo(TEmpBaseInfoTemp baseInfo) {
        String sql = "insert into t_emp_base_info_temp (id,erp_no,name,sex,birth_date,nation,birth_place,born_place,politi_status,id_card_no,mobile_phone,level,salary_grade,party_date,job_date,unit,dept,cur_post,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{erp_no,jdbcType=VARCHAR},")
                .append("#{name,jdbcType=VARCHAR},").append("#{sex,jdbcType=VARCHAR},")
                .append("#{birth_date,jdbcType=VARCHAR},").append("#{nation,jdbcType=VARCHAR},")
                .append("#{birth_place,jdbcType=VARCHAR},").append("#{born_place,jdbcType=VARCHAR},").append("#{politi_status,jdbcType=VARCHAR},")
                .append("#{id_card_no,jdbcType=VARCHAR},").append("#{mobile_phone,jdbcType=VARCHAR},")
                .append("#{level,jdbcType=VARCHAR},").append("#{salary_grade,jdbcType=VARCHAR},")
                .append("#{party_date,jdbcType=DATE},").append("#{job_date,jdbcType=DATE},")
                .append("#{unit,jdbcType=VARCHAR},").append("#{dept,jdbcType=VARCHAR},")
                .append("#{cur_post,jdbcType=VARCHAR},").append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=DATE},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", baseInfo.getId());
        params.put("erp_no", baseInfo.getErpNo());
        params.put("name", baseInfo.getName());
        params.put("sex", baseInfo.getSex());
        params.put("birth_date", baseInfo.getBirthDate());
        params.put("nation", baseInfo.getNation());
        params.put("birth_place", baseInfo.getBirthPlace());
        params.put("born_place", baseInfo.getBornPlace());
        params.put("politi_status", baseInfo.getPolitiStatus());
        params.put("id_card_no", baseInfo.getIdCardNo());
        params.put("mobile_phone", baseInfo.getMobilePhone());
        params.put("level", baseInfo.getLevel());
        params.put("salary_grade", baseInfo.getSalaryGrade());
        params.put("party_date", baseInfo.getPartyDate());
        params.put("job_date", baseInfo.getJobDate());
        params.put("unit", baseInfo.getUnit());
        params.put("dept", baseInfo.getDept());
        params.put("cur_post", baseInfo.getCurPost());
        params.put("org_id", baseInfo.getOrgId());
        params.put("creater_id", baseInfo.getCreaterId());
        params.put("creater_name", baseInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", baseInfo.getUpdaterId());
        params.put("updater_name", baseInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", baseInfo.getIsValid());
        params.put("audit_state", baseInfo.getAuditState());
        params.put("orignal_id", baseInfo.getOrignalId());
        params.put("business_type_id", baseInfo.getBusinessTypeId());
        params.put("primitive_id", baseInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }

}
